package com.uzai.console.service.feign.impl;

import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.BaseDto;
import com.uzai.console.dto.feign.uzaicms.CmsDtkTbGoodsDetailDto;
import com.uzai.console.dto.feign.uzaicms.CmsTbGoodsSuperSearchDto;
import com.uzai.console.dto.feign.uzaicms.CmsTbGoodsTypeSearchDto;
import com.uzai.console.service.feign.UzaiCmsFeignService;
import com.uzai.console.vo.cms.tbgoods.CmsTbGoodsFirstTypeVo;
import com.uzai.console.vo.cms.tbgoods.CmsTbGoodsInfoQueryResultVo;
import com.uzai.console.vo.cms.tbgoods.CmsTbGoodsInfoVo;
import com.uzai.console.vo.cms.tbgoods.DtkGoodsDetailVo;
import com.uzai.console.vo.feign.uzaicms.*;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: liuqi
 * @Date: 2021/11/24 16:24
 * @Description:
 */
@Component
public class UzaiCmsFeignFallbackFactory implements FallbackFactory<UzaiCmsFeignService> {

    private static Logger logger = LoggerFactory.getLogger(UzaiCmsFeignFallbackFactory.class);

    @Override
    public UzaiCmsFeignService create(Throwable throwable) {

        logger.error("--cms功能调用微服务出错，err:={}", throwable);

        return new UzaiCmsFeignService() {
            @Override
            public UzaiRespVo<SupperSearchVo> superSearch(CmsTbGoodsSuperSearchDto cmsTbGoodsSuperSearch) {
                UzaiRespVo<SupperSearchVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<List<CmsTbGoodsFirstTypeVo>> firstTypeList() {
                UzaiRespVo<List<CmsTbGoodsFirstTypeVo>> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<TypeSearchVo> typeSearch(@RequestBody CmsTbGoodsTypeSearchDto cmsTbGoodsTypeSearchDto){
                UzaiRespVo<TypeSearchVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<List<CMSBanner>> homeActCarouseList(@RequestBody BaseDto baseDto){
                UzaiRespVo<List<CMSBanner>> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<List<CMSBanner>> homeActDiscountHeadline(@RequestBody BaseDto baseDto){
                UzaiRespVo<List<CMSBanner>> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<List<HomeActNavEntity>> homeActNavList(@RequestBody BaseDto baseDto){
                UzaiRespVo<List<HomeActNavEntity>> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<DtkGoodsDetailVo> dtkGoodsDetailSingle(@RequestBody CmsDtkTbGoodsDetailDto cmsDtkTbGoodsDetailDto){
                UzaiRespVo<DtkGoodsDetailVo> uzaiRespVo = new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }


        };
    }

}
